package com.link.base.base.product.controller;

import com.link.base.base.product.model.ProdChange;
import com.link.base.base.product.service.ProdChangeService;
import com.link.core.basic.annotations.JsonParam;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.KeyGenerateService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * 设计变动
 *
 * @author 阳晓琳
 * @date 2020-10-14 19:28:02
 */
@Controller
@RequestMapping("/link/prodChange")
public class ProdChangeController extends BasicController<ProdChange> {

    @Resource
    private KeyGenerateService keyGenerateService;

    @Resource
    private ProdChangeService prodChangeService;

    @Override
    public BasicService<ProdChange> getBasicService() throws Exception {
        return prodChangeService;
    }

    /**
     * 设变信息审批
     * @author 王昊
     * @param entity
     * @param session
     * @param request
     * @return
     */
    @RequestMapping(value = "/prodChangeSubmit" , method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> prodChangeSubmit(@JsonParam ProdChange entity, HttpSession session, HttpServletRequest request) {
        Map<String,Object> result = new HashMap<>(4);
        try {
            prodChangeService.prodChangeSubmit(entity);
            result.put("newRow",entity);
            result.put("success",true);
        } catch (Exception e) {
            result.put("success",false);
            result.put("result", e.getMessage());
        }
        return result;
    }
}